import type { NextApiRequest, NextApiResponse } from "next";
import fs from "fs";
import VisFragment from "@/types/VisFragment";
import { ResData } from "@/types/typesInForm/ResData";

export default function handler(req: NextApiRequest, res: NextApiResponse) {
  fs.readFile("./outputGit.json", "utf8", function (err, data) {
    if (err) console.log(err);
    else {
      const f: VisFragment = JSON.parse(data);
      const wrapper: ResData<VisFragment> = {
        ifSuccessful: true,
        data: f,
        message: "",
      };
      res.status(200).json(wrapper);
    }
  });
}
